-
Notifications
You must be signed in to change notification settings - Fork 0
Next.js API Integration for Universal Deployment #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ation
🔧 Problem Solved:
- View Proof functionality was broken for all users
- Frontend was trying direct Golem DB connection (browser limitations)
- No universal solution for accessing verification data
✅ Solution Implemented:
- Updated frontend to use backend API with environment variable configuration
- Added NEXT_PUBLIC_API_BASE_URL for flexible deployment
- Enhanced golem_endpoints.py with proper fetch functions
- Added /golem-verification/{user_id} endpoint to biometrics server
🚀 Deployment Ready:
- Local development: Uses http://localhost:8001 (existing service)
- Production: Uses NEXT_PUBLIC_API_BASE_URL environment variable
- Backend service: golem-endpoints on port 8001
- Required env vars: PRIVATE_KEY, GOLEM_DB_RPC, GOLEM_DB_WSS, GOLEM_APP_TAG
📊 Verified Working:
- API endpoint: /api/v1/verification-by-user/{user_id}
- Returns real Golem DB data with all annotations
- Entity keys, humanity scores, timestamps all working
- Source: golem_db ✅
Ready for Kubernetes deployment! 🎉
…ment - Add Next.js API route /api/verification-by-user/[userId] - Install golem-base-sdk in frontend project - Update verification-hero.tsx to call local API - Ready for Vercel deployment with environment variables - Fixes View Proof functionality for all users
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 issues found across 4 files
React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| PRIVATE_KEY | ||
| ); | ||
| const data = await response.json(); | ||
| console.log('✅ Next.js API response:', data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrestricted console logging in production may leak identifiers and clutter logs; gate these logs behind a dev check or remove them.
Prompt for AI agents
Address the following comment on frontend/src/app/(app)/home/_components/verification-hero.tsx at line 55:
<comment>Unrestricted console logging in production may leak identifiers and clutter logs; gate these logs behind a dev check or remove them.</comment>
<file context>
@@ -36,109 +35,40 @@ export function VerificationHero() {
- PRIVATE_KEY
- );
+ const data = await response.json();
+ console.log('✅ Next.js API response:', data);
- console.log('✅ Connected to Golem DB, searching for user_id:', targetUserId);
</file context>
|
|
||
| # If this matches our criteria and is newer than current latest | ||
| if is_target_user and is_humanity_verification and entity_timestamp: | ||
| if not latest_timestamp or entity_timestamp > latest_timestamp: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing timestamp strings can return the wrong latest record; parse to datetime for reliable ordering.
Prompt for AI agents
Address the following comment on biometrics_server/golem_endpoints.py at line 424:
<comment>Comparing timestamp strings can return the wrong latest record; parse to datetime for reliable ordering.</comment>
<file context>
@@ -350,6 +350,106 @@ async def fetch_all_verifications() -> list[dict]:
+
+ # If this matches our criteria and is newer than current latest
+ if is_target_user and is_humanity_verification and entity_timestamp:
+ if not latest_timestamp or entity_timestamp > latest_timestamp:
+ # Get the full entity data
+ entity_key_hex = entity_key.as_hex_string()
</file context>
| if not latest_timestamp or entity_timestamp > latest_timestamp: | |
| if not latest_timestamp or datetime.fromisoformat(entity_timestamp.replace('Z', '+00:00')) > datetime.fromisoformat(latest_timestamp.replace('Z', '+00:00')): |
| return None | ||
|
|
||
| except Exception as e: | ||
| print(f"❌ Failed to fetch from Golem DB: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the error logger instead of print to capture exceptions in logs.
Prompt for AI agents
Address the following comment on biometrics_server/golem_endpoints.py at line 387:
<comment>Use the error logger instead of print to capture exceptions in logs.</comment>
<file context>
@@ -350,6 +350,106 @@ async def fetch_all_verifications() -> list[dict]:
+ return None
+
+ except Exception as e:
+ print(f"❌ Failed to fetch from Golem DB: {e}")
+ return None
+
</file context>
| print(f"❌ Failed to fetch from Golem DB: {e}") | |
| logger.error(f"❌ Failed to fetch from Golem DB: {e}") |
| print(f"✅ Verification found for user {user_id}") | ||
| return verification_data | ||
| else: | ||
| print(f"❌ No verification found for user {user_id}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the configured logger instead of print for consistency and observability.
Prompt for AI agents
Address the following comment on biometrics_server/golem_endpoints.py at line 383:
<comment>Use the configured logger instead of print for consistency and observability.</comment>
<file context>
@@ -350,6 +350,106 @@ async def fetch_all_verifications() -> list[dict]:
+ print(f"✅ Verification found for user {user_id}")
+ return verification_data
+ else:
+ print(f"❌ No verification found for user {user_id}")
+ return None
+
</file context>
| print(f"❌ No verification found for user {user_id}") | |
| logger.info(f"❌ No verification found for user {user_id}") |
| verification_data = future.result(timeout=30) # 30 second timeout | ||
|
|
||
| if verification_data: | ||
| print(f"✅ Verification found for user {user_id}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the configured logger instead of print for consistency and proper log handling.
Prompt for AI agents
Address the following comment on biometrics_server/golem_endpoints.py at line 380:
<comment>Use the configured logger instead of print for consistency and proper log handling.</comment>
<file context>
@@ -350,6 +350,106 @@ async def fetch_all_verifications() -> list[dict]:
+ verification_data = future.result(timeout=30) # 30 second timeout
+
+ if verification_data:
+ print(f"✅ Verification found for user {user_id}")
+ return verification_data
+ else:
</file context>
| print(f"✅ Verification found for user {user_id}") | |
| logger.info(f"✅ Verification found for user {user_id}") |
| elif annotation.key == "recordType" and annotation.value == "humanity_verification": | ||
| is_humanity_verification = True | ||
| elif annotation.key == "timestamp": | ||
| entity_timestamp = annotation.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing timestamp strings may select the wrong latest verification; parse to datetime for robust ordering.
Prompt for AI agents
Address the following comment on biometrics_server/main_fastapi.py at line 635:
<comment>Comparing timestamp strings may select the wrong latest verification; parse to datetime for robust ordering.</comment>
<file context>
@@ -593,6 +593,94 @@ async def get_verification_status(user_id: str):
+ elif annotation.key == "recordType" and annotation.value == "humanity_verification":
+ is_humanity_verification = True
+ elif annotation.key == "timestamp":
+ entity_timestamp = annotation.value
+
+ # If this matches our criteria and is newer than current latest
</file context>
| raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}") | ||
|
|
||
| @app.get("/golem-verification/{user_id}") | ||
| async def get_golem_verification_by_user(user_id: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This endpoint re-implements logic that already exists in golem_endpoints.fetch_verification_by_user_id; prefer calling the shared function to avoid duplication and divergence.
Prompt for AI agents
Address the following comment on biometrics_server/main_fastapi.py at line 597:
<comment>This endpoint re-implements logic that already exists in golem_endpoints.fetch_verification_by_user_id; prefer calling the shared function to avoid duplication and divergence.</comment>
<file context>
@@ -593,6 +593,94 @@ async def get_verification_status(user_id: str):
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
+@app.get("/golem-verification/{user_id}")
+async def get_golem_verification_by_user(user_id: str):
+ """Get verification data directly from Golem DB by searching for user_id annotation"""
+ try:
</file context>
Integrates Golem DB directly into Next.js API routes for universal deployment. Fixes View Proof functionality for all users by removing localhost dependencies.
Summary by cubic
Routes Golem DB access through a Next.js API and backend endpoints to enable universal deployment and fix the View Proof flow for all users. Removes localhost and browser-side SDK dependencies so verification data loads reliably.
New Features
Migration